package ModelLayer;
import java.util.*;

/**
 * Write a description of class DVDCollection here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LeaseContainer
{
    // instance variables - replace the example below with your own
    private ArrayList<Lease>  loanContainer;
    private static LeaseContainer instance;
    /**
     * Constructor for objects of class DVDCollection
     */
    public LeaseContainer()
    {
        loanContainer = new ArrayList<Lease>();
    }

    public static LeaseContainer getInstance(){
        if (instance == null){
            instance = new LeaseContainer();
        }
        return instance;
    }

    public Lease findLease(int id)
    {
        Lease lObject = null;
        int index = 0;
        boolean found = false;
        while(index < loanContainer.size() && !found)
        {
            lObject = loanContainer.get(index); 
            if(lObject.getLeaseId() == id)
            {
                found = true;
            }
            else
            {
                index++;
            }
        }//end while
        return loanContainer.get(index);
    }
    

    public void addLease(Lease l)
    {
        loanContainer.add(l);
    }

    public void deleteLease(Lease l)
    {
        if(loanContainer.contains(l))
            loanContainer.remove(l);
    }

}
